package com.rongcheng.frc.newstyledemo.utils;

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;

import com.rongcheng.frc.newstyledemo.engine.YoungHeartApplication;

/**
 * Created by frc on 16-6-14.
 */
public class Util {
    /**
     * 获取密度
     *
     * @return
     */
    public static String getDensity() {
        DisplayMetrics dm = YoungHeartApplication.getInstance().getResources().getDisplayMetrics();
        return String.valueOf(dm.density);
    }

    /**
     * 获取分辨率
     *
     * @return
     */
    public static String getResolution() {
        DisplayMetrics dm = YoungHeartApplication.getInstance().getResources().getDisplayMetrics();
        return new StringBuilder().append(dm.widthPixels).append("*").append(dm.heightPixels).toString();
    }

    /**
     * 得到屏幕的宽度
     *
     * @return
     */
    public static int getScreenWidth() {
        return ((WindowManager) YoungHeartApplication.getInstance().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
    }

    /**
     * 得到屏幕的高度
     *
     * @return
     */
    public static int getScreenHeight() {
        return ((WindowManager) YoungHeartApplication.getInstance().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight();
    }

}
